function(glsl2inc glsl_file inc_dir out)
    # get fileName and fileExt
	get_fileName_component(fileName ${glsl_file} NAME_WE)
	get_fileName_component(fileExt ${glsl_file} EXT)
    # make ext to upper case
    string(TOUPPER ${fileExt} fileExt)
	# make fileName like simple.VS.inc
	set(gen_file "${inc_dir}/${fileName}${fileExt}.inc")
	# message("INFO: Generate inc file ${gen_file}")
    # 清空输出文件
    file(WRITE ${gen_file} "")
	# for c compatibility
    string(MAKE_C_IDENTIFIER "${fileName}${fileExt}" token)
    # read from file
	file(READ ${glsl_file} content)
	# replace " to \"
	string(REGEX REPLACE "\"" "\\\\\"" content "${content}")
	# replace '\r'+'\n' to '\'+'n'+'"'+'\n'
	string(REGEX REPLACE "[\r\n]" "\\\\n\"\\\\\n\"" content "${content}")
	# Preceded by '"', followed by '/'+'"'
	set(content "\"${content}\"")
	# insert the code for the definition of the variable and write file
	file(APPEND ${gen_file} "const char *glsl_${token} = \n${content};\n")
	# return gen_file
	set(${out} ${gen_file} PARENT_SCOPE)
endfunction()

function(glsldir2inc target glsl_dir)
	# build destination dir
	set (inc_dir "${CMAKE_CURRENT_BINARY_DIR}/glsl")
	# make destination dir
	file(MAKE_DIRECTORY ${inc_dir})
	if(NOT EXISTS ${inc_dir})
		# message warning
		message(WARNING "Unable to make directory ${inc_dir}!")
	else()
		# get all glsl files in glsl_dir
		file(GLOB srcFiles ${glsl_dir}/*)
		# Process the glsl files one by one
		foreach(srcfile ${srcFiles})
			# call glsl2inc gen one glslinc file
			glsl2inc(${srcfile} ${inc_dir} glslinc_file)
			# append glslinc file tu list glslinc_files
			list(APPEND glslinc_files ${glslinc_file})
		endforeach()
		
		# append glslinc dir tu target include path
		target_include_directories(${target} PRIVATE ${inc_dir})
		# message("INFO: append include path ${inc_dir} to [${target}]")
		# append the inc file as the source file for the target
		target_sources(${target} PUBLIC ${glslinc_files})
		# Add generation process of the glslinc files as a custom target 
		# to the list of dependent targets for the target
		set(gen_target "gen-${target}-glslInc")
		add_custom_target(
			${gen_target}
			DEPENDS ${glslinc_files}
		)
		add_dependencies(${target} ${gen_target})
		message(STATUS "add dependencies target [${gen_target}] to [${target}]")
	endif()

endfunction()